<template>
  <div class="personal_box_container">
    <!-- 头部 -->
    <div class="personal_header">
      <!-- 设置 -->
      <div class="set_box">
        <van-icon name="setting-o" @click="onset" />
      </div>
      <!-- 登录注册 -->
      <div class="login_box">
        <div class="headPortrait">
          <div class="img_box">
            <img src="../assets/img/headportrait.png" alt="" v-show="show" />
            <img src="../assets/img/头像2.png" alt="" v-show="show2" />
          </div>
          <div class="font">
            <span @click="onClickLogin" v-show="show">登陆/注册</span>
            <span v-show="show2">{{ this.$store.state.mobiles }}</span>
          </div>
        </div>
      </div>
    </div>
    <!-- 订单 -->
    <div class="commodity_message">
      <!-- 商品 -->
      <div class="commodity" @click="onClick">
        <div>
          <div class="iconfont icon-truck"></div>
          <div class="font1">我的订单</div>
          <div class="font2">买课发快递</div>
        </div>
      </div>
      <div class="commodity1" @click="onClick1">
        <div>
          <div class="iconfont icon-duihuan"></div>
          <div class="font1">兑换课程</div>
          <div class="font2">兑换码兑换课程</div>
        </div>
      </div>
      <div class="commodity2" @click="onClick2">
        <div>
          <div class="iconfont icon-dizhi"></div>
          <div class="font1">地址管理</div>
          <div class="font2">收货地址</div>
        </div>
      </div>
    </div>
    <!-- 收藏 -->
    <div class="collect_box">
      <div class="detail_box" @click="onClickS">
        <div class="left_box">
          <div class="iconfont icon-shoucang"></div>
          <div class="collect">我的收藏</div>
        </div>
        <div class="right_box">
          <van-icon name="arrow" />
        </div>
      </div>

      <div class="detail_box1" @click="onClickH">
        <div class="left_box">
          <div class="iconfont icon-huiyuan"></div>
          <div class="collect">我的会员</div>
        </div>
        <div class="right_box">
          <van-icon name="arrow" />
        </div>
      </div>

      <div class="detail_box2" @click="onClickY">
        <div class="left_box">
          <div class="iconfont icon-youhuijuan"></div>
          <div class="collect">我的优惠券</div>
        </div>
        <div class="right_box">
          <van-icon name="arrow" />
        </div>
      </div>
    </div>
    <!-- 消息 -->
    <div class="information">
      <div class="detail_box" @click="onClickX">
        <div class="left_box">
          <div class="iconfont icon-xiaoxi"></div>
          <div class="collect">我的消息</div>
        </div>
        <div class="right_box">
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="detail_box1" @click="onClickF">
        <div class="left_box">
          <div class="iconfont icon-bianji"></div>
          <div class="collect">问题反馈</div>
        </div>
        <div class="right_box">
          <van-icon name="arrow" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: true,
      show2: false,
      mobile: this.$store.state.mobiles,
    };
  },
  created() {
    this.getToken();
  },
  methods: {
    onClickLogin() {
      this.$router.push({ path: "/login" });
    },
    getToken() {
      const token = sessionStorage.getItem("token");
      // console.log(token);
      if (token) {
        this.show2 = true;
        this.show = false;
      } else {
        this.show = true;
        this.show2 = false;
      }
    },
    onClick() {
      this.$router.push({ path: "/order" });
    },
    onClick1() {
      this.$router.push({ path: "/course" });
    },
    onClick2() {
      this.$router.push({ path: "/site" });
    },
    onClickS() {
      this.$router.push({ path: "/collect" });
    },
    onClickH() {
      this.$router.push({ path: "/vip" });
    },
    onClickY() {
      this.$router.push({ path: "/coupon" });
    },
    onClickX() {
      this.$router.push({ path: "/information" });
    },
    onClickF() {
      this.$router.push({ path: "/issue" });
    },
    onset() {
      this.$router.push({ path: "/set" });
    },
  },
};
</script>

<style lang="scss">
.personal_box_container {
  width: 100vw;
  height: 100vh;
  background-color: #f4f4f4;
  .personal_header {
    width: 100%;
    height: 4rem;
    // background-color: red;
    background-image: url("../assets/img/user_bg.85d8e725.png");
    background-repeat: no-repeat;
    .set_box {
      width: 100%;
      height: 1rem;
      // background-color: red;
      display: flex;
      justify-content: flex-end;
      align-items: center;
      i {
        font-size: 25px;
        margin-right: 20px;
        color: #fff;
      }
    }
    .login_box {
      width: 100%;
      height: 3rem;
      // background-color: skyblue;
      display: flex;
      justify-content: center;
      align-items: center;
      .headPortrait {
        width: 3rem;
        height: 2.5rem;
        // background-color: green;
        .img_box {
          width: 90px;
          height: 90px;
          // background-color: skyblue;
          border-radius: 50%;
          margin: 0 auto;
          display: flex;
          justify-content: center;
          align-items: center;
          img {
            width: 99%;
            height: 99%;
            border-radius: 50%;
          }
        }
        .font {
          width: 100%;
          // background-color: skyblue;
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 20px;
          margin-top: 10px;
          color: #fff;
        }
      }
    }
  }
  .commodity_message {
    width: 100%;
    height: 1.5rem;
    background-color: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    .commodity,
    .commodity1,
    .commodity2 {
      width: 30%;
      height: 85%;
      // background-color: grey;
      border-right: 1px solid #ccc transparent;
      display: flex;
      justify-content: center;
      align-items: center;
      .iconfont {
        margin-left: 25px;
        font-size: 25px;
      }
      .font1 {
        font-size: 12px;
        margin-top: 10px;
        margin-left: 10px;
      }
      .font2 {
        font-size: 12px;
        margin-left: 10px;
        color: #ccc;
        margin-top: 5px;
      }
    }
  }

  .collect_box {
    width: 100%;
    height: 3rem;
    // background-color: rebeccapurple;
    margin-top: 10px;
    margin-left: 3px;
  }
  .detail_box,
  .detail_box1,
  .detail_box2 {
    width: 100%;
    height: 1rem;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left_box {
      display: flex;
      .iconfont {
        font-size: 22px;
        margin-left: 5px;
      }
      .collect {
        font-size: 18px;
        margin-top: 5px;
      }
    }
    .right_box {
      width: 30px;
      display: flex;
      align-items: center;
      i {
        font-size: 20px;
        color: #ccc;
      }
    }
  }
  .information {
    width: 100%;
    height: 2rem;
    // background-color: red;
    margin-top: 15px;
  }
}
</style>